import { createStore } from 'vuex'; // 创建一个新的 store 实例
import persistedState from 'vuex-persistedstate';
import SecureLS from 'secure-ls';
const ls = new SecureLS({ isCompression: false });
const store = createStore({
  state() {
    return {
      count: 0,
      siderBarType: 1,
      themeType: 'green',
    };
  },
  mutations: {
    setSiderBarType(state, payload) {
      state.siderBarType = payload;
    },
    setCount(state, payload) {
      state.count = payload;
    },
  },
  actions: {},
  plugins: [
    persistedState({
      storage: {
        getItem: key => ls.get(key),
        setItem: (key, value) => ls.set(key, value),
        removeItem: key => ls.remove(key),
      },
    }),
  ],
});

export default store;
